// var i;
// var $resKeeper = require("./ResKeeper");
// var s = cc._decorator;
// var l = s.ccclass;
// var u = s.property;
// var d = s.inspector;
// var p = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.linpinShiPei = 0;
//         t.deftop = 0;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         var e = this;
//         this.scheduleOnce(function () {
//             var t = e.node.getComponent(cc.Widget);
//             if (t) {
//                 if (0 == e.deftop) {
//                     e.deftop = t.top;
//                 }
//                 var o = e.deftop;
//                 if (cc.winSize.height / cc.winSize.width > 2) {
//                     t.top = o + e.linpinShiPei;
//                     t.updateAlignment();
//                 }
//             }
//         });
//     };
//     __decorate([u()], t.prototype, "linpinShiPei", void 0);
//     return __decorate([l], t);
// })($resKeeper.default);
// exports.default = p;

import ResKeeper from "./ResKeeper";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名：ResKeeperComponent
 */
@ccclass
class DingbuShipei extends ResKeeper {
    /** 
     * 适配比例 
     * 建议变量名：adaptationRatio
     */
    @property()
    linpinShiPei: number = 0;

    /** 
     * 默认顶部距离 
     * 建议变量名：defaultTop
     */
    deftop: number = 0;

    /**
     * 当组件启用时调用
     * 建议方法名：handleEnable
     */
    onEnable() {
        this.scheduleOnce(() => {
            const widgetComponent = this.node.getComponent(cc.Widget);
            if (widgetComponent) {
                if (this.deftop === 0) {
                    this.deftop = widgetComponent.top;
                }
                const originalTop = this.deftop;
                if (cc.winSize.height / cc.winSize.width > 2) {
                    widgetComponent.top = originalTop + this.linpinShiPei;
                    widgetComponent.updateAlignment();
                }
            }
        });
    }
}

export default DingbuShipei;